package org.scs.carleton.ca.pgdt.core.ui.internal.highlighting;

import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.TextAttribute;
import org.eclipse.jface.text.presentation.IPresentationReconciler;
import org.eclipse.jface.text.presentation.PresentationReconciler;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;

/**
 * Source viewer configuration
 * 
 * @author tessierj
 */
public class PrologSourceViewerConfiguration extends TextSourceViewerConfiguration {
	private ColorManager colorManager;
	
	public PrologSourceViewerConfiguration(ColorManager colorManager) {
		this.colorManager = colorManager;
	}
	
	@Override
	public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
		PresentationReconciler reconciler = new PrologPresentationReconciler();
		
		NonRuleBasedDamagerRepairer damagerRepairer = new NonRuleBasedDamagerRepairer(new TextAttribute(colorManager.getColor(IPrologColorConstants.COMMENT)));
		reconciler.setDamager(damagerRepairer, PrologPartitionScanner.PROLOG_COMMENT);
		reconciler.setRepairer(damagerRepairer, PrologPartitionScanner.PROLOG_COMMENT);
		
		return reconciler;
	}

	@Override
	public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
		return new String[] { IDocument.DEFAULT_CONTENT_TYPE, PrologPartitionScanner.PROLOG_COMMENT };
	}
}
